<?php

namespace App\Repositories\Address;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\Address\DeliverRegionOrderPeakRepository;
use App\Models\Address\DeliverRegionOrderPeak;
use App\Validators\Address\DeliverRegionOrderPeakValidator;

/**
 * Class DeliverRegionOrderPeakRepositoryEloquent.
 *
 * @package namespace App\Repositories\Address;
 */
class DeliverRegionOrderPeakRepositoryEloquent extends BaseRepository implements DeliverRegionOrderPeakRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return DeliverRegionOrderPeak::class;
    }

    /**
    * Specify Validator class name
    *
    * @return mixed
    */
    public function validator()
    {

        return DeliverRegionOrderPeakValidator::class;
    }


    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }

    /**
     * 获取区域订单峰值信息
     * @author Min
     * @param $wdr_id 区域id
     * @return mixed
     */
    public function getOrderPeakByWdrId($wdr_id)
    {
        $where = array(
            'wdr_id' => $wdr_id
        );

        $field = ['order_peak','is_free_single','time_id'];

        return $this->findWhere($where, $field)->toArray();
    }

}
